/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number[]}
 */
var searchRange = function(nums, target) {
  let left = 0, right = nums.length - 1
   let ans = [-1, -1]
   while(left <= right) {
     let mid = (left + right) >> 1
     if(target < nums[mid]) {
       right = mid - 1
     } else if(target == nums[mid]) {
       right = mid - 1
       ans[0] = mid
     } else {
       left = mid + 1
     }
   }
   left = 0
   right = nums.length - 1
   while(left <=  right) {
     let mid = (left + right) >> 1
     if(target < nums[mid]) {
       right = mid - 1
     } else if(target == nums[mid]) {
       left = mid  + 1
       ans[1] = mid
     } else {
       left = mid + 1
     }
   }
   return ans
 };